import request from '../util/httpTool'
import DeviceSettingSendReq from "../req/DeviceSettingSendReq";
import DeviceSettingListReq from "../req/DeviceSettingListReq";
import {AxiosPromise} from "axios";
import DeviceSendRes from "../res/DeviceSendRes";
import DeviceSensorDataWithExplain from "../res/DeviceSensorDataWithExplain";
import DeviceSensorData from "../res/DeviceSensorData";
import DeviceSettingWithParamList from "../res/DeviceSettingWithParamList";


const basePath = 'iot/api/v1/v1/device/setting/'

export function list(req: DeviceSettingListReq): Promise<DeviceSettingWithParamList[]> {
    return new Promise<DeviceSettingWithParamList[]>((resolve, reject) => {
        const res: any = request({
            url: basePath + 'list',
            method: 'post',
            data: req
        })
        res.then((data: DeviceSettingWithParamList[]) => {
            resolve(data)
        }).catch((e: any) => {
            reject(e)
        })
    })
}

export function send(req: DeviceSettingSendReq): Promise<DeviceSendRes> {
    return new Promise<DeviceSendRes>((resolve, reject) => {
        const res: any = request({
            url: basePath + 'send',
            method: 'post',
            data: req
        })
        res.then((data: DeviceSendRes) => {
            resolve(data)
        }).catch((e: any) => {
            reject(e)
        })
    })
}


